<!doctype html>
<html lang="en" class="fixed">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <title>编辑学员</title>
    <link rel="apple-touch-icon" sizes="120x120" href="favicon/apple-icon-120x120.png">
    <link rel="icon" type="image/png" sizes="192x192" href="favicon/android-icon-192x192.png">
    <link rel="icon" type="image/png" sizes="32x32" href="favicon/favicon-32x32.png">
    <link rel="icon" type="image/png" sizes="16x16" href="favicon/favicon-16x16.png">
    <link rel="stylesheet" type="text/css" href="http://static.test-crm.classba.com.cn/assets/plugins/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="http://static.test-crm.classba.com.cn/assets/plugins/bootstrap/css/bootstrap-datetimepicker.min.css">
    <link rel="stylesheet" type="text/css" href="http://static.test-crm.classba.com.cn/assets/plugins/bootstrap/css/build_standalone.css">
    <link rel="stylesheet" type="text/css" href="http://static.test-crm.classba.com.cn/assets/plugins/bootstrap/css/build.css">
    <link rel="stylesheet" href="http://static.test-crm.classba.com.cn/assets/plugins/animate.css/animate.css">
    <link rel="stylesheet" href="http://static.test-crm.classba.com.cn/assets/plugins/font-awesome/css/font-awesome.css">
    <link rel="stylesheet" href="http://static.test-crm.classba.com.cn/assets/plugins/data-table/media/css/dataTables.bootstrap.min.css">
    <link rel="stylesheet" href="http://static.test-crm.classba.com.cn/assets/plugins/ztree/css/zTreeStyle/zTreeStyle.css">
    <link rel="stylesheet" href="http://static.test-crm.classba.com.cn/app/css/style.css">
    <link rel="stylesheet" href="http://static.test-crm.classba.com.cn/assets/plugins/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="http://static.test-crm.classba.com.cn/app/css/app.css">
    <!-- bootstarp css -->
    <link rel="stylesheet" href="bootstrap/css/bootstrap.css">
    <!-- bootstarp css -->
    <link rel="stylesheet" href="style/main.css">
</head>

<body>
    <div class="fix-head">
        <h1 style="color:#fff">LOGO</h1>
    </div>
    <div class="row class-wrap">
        <div class="col-md-1 nav-wrap">
            <nav id="nav" class="navbar-default navbar-static-side" role="navigation">
                <div class="sidebar-nav">
                    <ul id="tree7" class="tree">
                        <li>
                            <a href="">短信管理</a>
                        </li>
                        <li>
                            <a href="">用户列表</a>
                        </li>
                        <li>
                            <a href="">分组管理</a>
                        </li>
                        <li>
                            <a href="">角色权限</a>
                        </li>
                    </ul>
                </div>
            </nav>
        </div>
        <div class="col-md-11 class-main">
            <div class="title-top">
                <h1>学员信息</h1>
            </div>
            <div class="class-box">
                <div class="class-box-head">
                    <div class="class-box-title">
                        <h3>基本信息</h3>
                    </div>
                </div>
                <div class="class-box-body">
                    <div class="form-horizontal">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">学员姓名：</label>
                            <div class="col-sm-10">
                                <input type="text" name="sname" class="form-control" value="yaoyingyu">
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>

                        <div class="form-group">
                            <label class="col-sm-2 control-label">联系手机：</label>
                            <div class="col-sm-10">
                                <input type="text" name="sname" class="form-control" value="yaoyingyu">
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>

                        <div class="form-group">
                            <label class="col-sm-2 control-label">家庭座机：</label>
                            <div class="col-sm-10">
                                <input type="text" name="sname" class="form-control" value="yaoyingyu">
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>


                        <div class="form-group">
                            <label class="col-sm-2 control-label">性别：</label>
                            <div class="col-sm-10">
                                <select name="sex" id="" class="form-control">
                                    <option value="">请选择</option>
                                    <option value="male">男</option>
                                    <option value="female">女</option>
                                </select>
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>

                        <div class="form-group">
                            <label class="col-sm-2 control-label">地区：</label>
                            <div class="col-sm-10">
                                <div class="col-sm-3">
                                    <select id="cmbProvince" name="province" class="form-control" value="无"></select>
                                </div>
                                <div class="col-sm-3">
                                    <select id="cmbCity" name="city" class="form-control" value="无"></select>
                                </div>
                                <div class="col-sm-3">
                                    <select id="cmbArea" name="county" class="form-control" value=""></select>
                                </div>
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                    </div>
                </div>
            </div>
            <div class="class-box">
                <div class="class-box-head">
                    <div class="class-box-title">
                        <h3>其他信息</h3>
                    </div>
                </div>
                <div class="class-box-body">
                    <div class="form-horizontal">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">学员姓名：</label>
                            <div class="col-sm-10">
                                <input type="text" name="sname" class="form-control" value="yaoyingyu">
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>

                        <div class="form-group">
                            <label class="col-sm-2 control-label">联系手机：</label>
                            <div class="col-sm-10">
                                <input type="text" name="sname" class="form-control" value="yaoyingyu">
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>

                        <div class="form-group">
                            <label class="col-sm-2 control-label">家庭座机：</label>
                            <div class="col-sm-10">
                                <input type="text" name="sname" class="form-control" value="yaoyingyu">
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>


                        <div class="form-group">
                            <label class="col-sm-2 control-label">性别：</label>
                            <div class="col-sm-10">
                                <select name="sex" id="" class="form-control">
                                    <option value="">请选择</option>
                                    <option value="male">男</option>
                                    <option value="female">女</option>
                                </select>
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>

                        <div class="form-group">
                            <label class="col-sm-2 control-label">地区：</label>
                            <div class="col-sm-10">
                                <div class="col-sm-3">
                                    <select id="cmbProvince" name="province" class="form-control" value="无"></select>
                                </div>
                                <div class="col-sm-3">
                                    <select id="cmbCity" name="city" class="form-control" value="无"></select>
                                </div>
                                <div class="col-sm-3">
                                    <select id="cmbArea" name="county" class="form-control" value=""></select>
                                </div>
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                    </div>
                </div>
            </div>
            <div class="btns-group">
                <button class="btn btn-white btn-lg" id="cancel">取消</button>
                <button class="btn btn-primary btn-lg" id="save">确定</button>
            </div>
        </div>
    </div>
    <input type="hidden" name="save_user" value="http://test-crm.classba.com.cn/ajax/student/student/seveStudent" />
    <input type="hidden" name="uid" value="1398893" />
    <script src="http://static.test-crm.classba.com.cn/assets/plugins/jquery/jquery.min.js"></script>
    <script src="http://static.test-crm.classba.com.cn/assets/plugins/bootstrap/js/bootstrap.min.js"></script>
    <script src="http://static.test-crm.classba.com.cn/assets/plugins/data-table/media/js/jquery.dataTables.min.js"></script>
    <script src="http://static.test-crm.classba.com.cn/assets/plugins/data-table/media/js/dataTables.bootstrap.min.js"></script>
    <script src="http://static.test-crm.classba.com.cn/assets/plugins/bootstrap/js/bootstrap-datetimepicker.min.js"></script>
    <script src="http://static.test-crm.classba.com.cn/assets/plugins/bootstrap/js/bootstrap-datetimepicker.fr.js"></script>
    <script src="http://static.test-crm.classba.com.cn/assets/plugins/bootstrap/js/bootstrap-datetimepicker.zh-CN.js"></script>
    <script src="http://static.test-crm.classba.com.cn/assets/plugins/data-table/extensions/Responsive/js/dataTables.responsive.min.js"></script>
    <script src="http://static.test-crm.classba.com.cn/assets/plugins/data-table/extensions/Responsive/js/responsive.bootstrap.min.js"></script>
    <script src="http://static.test-crm.classba.com.cn/assets//plugins/ztree/js/jquery.ztree.core.js"></script>
    <script src="http://static.test-crm.classba.com.cn/assets/plugins/layui/layui.all.js" charset="utf-8"></script>
    <script type="text/javascript" src="http://static.test-crm.classba.com.cn/assets//plugins/ztree/js/jquery.ztree.excheck.js"></script>
    <script type="text/javascript" src="http://static.test-crm.classba.com.cn/assets//plugins/ztree/js/jquery.ztree.exedit.js"></script>
    <script src="http://static.test-crm.classba.com.cn/assets/js/city.js"></script>
    <script>
    $(function() {
        $(".form_datetime").datetimepicker({
            format: "yyyy-mm-dd",
            todayHighlight: true,
            autoclose: true,
            language: 'zh-CN',
            startView: 2,
            minView: 2,
            maxView: 2
        });
        $("#cancel").on("click", function() {
            window.parent.$('#index_tabs').tabs('close', '编辑学员');
        });
        addressInit('cmbProvince', 'cmbCity', 'cmbArea', "无", "无", "");
        $("#save").on("click", function() {
            var param = {};
            var stu_relation = {};
            param.id = $("input[name='uid']").val();
            param.sname = $("input[name='sname']").val();
            param.cellphone = $("input[name='cellphone']").val();
            param.telephone = $("input[name='telephone']").val();
            param.sex = $("select[name='sex']").val();
            param.age = $("input[name='age']").val();
            param.wechat = $("input[name='wechat']").val();
            param.qq = $("input[name='qq']").val();
            param.email = $("input[name='email']").val();
            param.channel_id = $("select[name='channel_id']").val();
            param.province = $("select[name='province']").val();
            param.city = $("select[name='city']").val();
            param.county = $("select[name='county']").val();
            param.home_address = $("input[name='home_address']").val();
            param.admission_time = $("input[name='admission_time']").val();
            param.school = $("input[name='school']").val();
            param.grade = $("select[name='grade']").val();
            param.intention = $("select[name='intention']").val();
            //            param.is_test = $("select[name='is_test']").val();
            param.twx_id = $("input[name='twx_id']").val();
            param.gw_id = $("input[name='gw_id']").val();
            param.gw_account = $("input[name='gw_account']").val();
            param.gw_password = $("input[name='gw_password']").val();
            param.cc_id = $("select[name='cc_id']").val();
            param.tmk_id = $("select[name='tmk_id']").val();
            param.is_treasure = 'no';
            param.cr_id = $("select[name='cr_id']").val();

            stu_relation = {
                0: {
                    id: $("input[name='relaion1_id']").val(),
                    relation: $("input[name='relation1']").val(),
                    full_name: $("input[name='full_name1']").val(),
                    cellphone: $("input[name='re_cellphone1']").val()
                },
                1: {
                    id: $("input[name='relaion2_id']").val(),
                    relation: $("input[name='relation2']").val(),
                    full_name: $("input[name='full_name2']").val(),
                    cellphone: $("input[name='re_cellphone2']").val()
                }
            }

            param.stu_relation = stu_relation;
            $.ajax({
                url: $("input[name='save_user']").val(),
                type: 'post',
                data: param,
                dataType: 'json',
                success: function(data) {
                    console.log(data);
                    if (data.success == 1) {
                        location.href = "/student/student/index"
                    } else {
                        layer.alert(data.msg);
                        console.log(data.errors);
                        var errors = data.errors;
                        for (var i in errors) {
                            //                            $("span.hidden_area").css("display","none")
                            $("span.hidden_area").each(function() {
                                console.log($(this).attr("data-name") == i);
                                if ($(this).attr("data-name") == i) {
                                    $(this).css("display", "inline");
                                    $(this).html(errors[i].message);
                                    layer.alert(errors[i].message);
                                }
                            })
                        }
                    }
                },
                complete: function() {

                },
                error: function() {

                }
            });
        });
    });
    </script>
</body>

</html>
